<template>
	<view class="wrap bgw">
		<view class="txtConten p30 pb100">
			<view class="txt text-lg p30">
				<p v-if="type == 'goods' "> {{data.name}} </p>
				<p v-if="type == 'goods' ">【售价】￥{{data.price}}</p>
				<p v-if="type == 'dynamic' "> {{data.title}} </p>
				复制这条信息
				<p class="one">(@ {{txt}} @)，</p>
				到【剧豆APP】即可
			</view>
			<button @tap="copy()" class="btnbg br42">复制文案</button>
		</view>

		<view class="sharesBottom p30">
			<view class="title"> <i class="br1"></i> 分享到 <i class="br2"></i> </view>
			<view class="sharesBottomBox">
				<view @tap="open('com.tencent.mm')">
					<image src="../../static/image/weixin.png" mode=""></image>
					微信
				</view>
				<view @tap="open('com.tencent.mobileqq')">
					<image src="../../static/image/QQ@2x.png" mode=""></image>
					QQ
				</view>
				<view @tap="open('com.sina.weibo')">
					<image src="../../static/image/weibo@2x.png" mode=""></image>
					微博
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		Base64
	} from '../../components/base64.js'
	export default {
		data() {
			return {
				data: [],
				txt: '',
				text: '',
				type: '',
			};
		},
		onLoad(e) {
			this.type = e.type
			this.data = uni.getStorageSync('judouPoster') 
			let ids = this.data.id 

			//  开发 环境
			if (process.env.NODE_ENV === 'development') {
				var  mpId = '__UNI__3FC7BE3'
			}else{
				var  mpId = plus.runtime.appid 
			} 
			mpId =  mpId.slice(7) 			 

			this.txt = `mpid:${mpId},id:${ids},type:${e.type}`
			this.txt = Base64.encode(this.txt); // 编码

			if (e.type == 'goods') {
				this.text = `${this.data.name}【在售价】￥${this.data.price} 复制这条信息，(@${this.txt}@) ，到【剧豆APP】即可`
			} else if (e.type == 'dynamic') {
				this.text = `${this.data.title} 复制这条信息，(@${this.txt}@) ，到【剧豆APP】即可`
			}

			// this.type = e.type
			// this.data = uni.getStorageSync('judouPoster')
			// let mpId = plus.runtime.appid
			// let ids = this.data.id
			// mpId = Base64.encode(mpId); // 编码
			// ids = Base64.encode(ids); // 编码
			// let type = Base64.encode(e.type); // 编码 

			// this.txt = `mpid:${mpId},id:${ids},type:${type}`
			// if (e.type == 'goods') {
			// 	this.text = `${this.data.name}【在售价】￥${this.data.price} 复制这条信息，(@${this.txt}@) ，到【剧豆APP】即可`
			// } else if (e.type == 'dynamic') {
			// 	this.text = `${this.data.title} 复制这条信息，(@${this.txt}@) ，到【剧豆APP】即可`
			// }
		},
		methods: {
			open(e) {
				plus.runtime.launchApplication({
					pname: e
				});
			},
			copy() {
				uni.setClipboardData({
					data: this.text,
					success: function() {
						uni.showToast({
							title: '复制成功'
						})
					}
				});
			},
		}
	}
</script>

<style lang="less" scoped>
	@import './index.less';
</style>
